// pages/mine/mineOrder/mineOrderDetail.js
var app = getApp();
import Api from '../../../api/api.js';
const api = new Api();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderId:"",
    deatailData:{},
    skuDict:{},
    express:null,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.data.orderId = options.orderId;
    this.getDetaildata();

  },
  getDetaildata() {
    var _this = this;
    var map = {};
    map.userId = app.USER_ID();
    map.appId = app.APP_ID;
    map.orderId = this.data.orderId;
    api.getRequestData(app.orderDetailUrl, map, true, "POST").then(res => {
      if (res.data.errorCode == 0) {
        var data = res.data.model;
        var list = data.children;
        _this.setData({
          deatailData:data,
          skuDict:list[0]
        });
        _this.getExpressDetaildata();
      } else {
        app.alert(res.data.errorMsg);
      }
    });
  },
  getExpressDetaildata() {
    var _this = this;
    var map = {};
    map.appId = app.APP_ID;
    map.orderId = this.data.orderId;
    api.getRequestData(app.expressDetailUrl, map, true, "GET").then(res => {
      if (res.data.errorCode == 0) {
        console.log(JSON.stringify(res.data.model));
        var result = res.data.model.result;
        _this.setData({
          express:result,
        });

      } else {
        app.alert(res.data.errorMsg);
      }
    });
  },
  copyExpress(e){
    var no = e.currentTarget.dataset.key;
    wx.setClipboardData({
      data: no,
      success(res){
        app.alert("复制成功~");
      },
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})